﻿using System.Collections.Generic;

using Ah.Testudin.Engine.Content;
using Ah.Testudin.Engine.Events;
using Ah.Testudin.Engine.Graphics;
using Ah.Testudin.Engine.Input;
using Ah.Testudin.Engine.UI.Elements;
using Ah.Testudin.Engine.UI.Elements.Inputs;
using Ah.Testudin.Engine.UI.Views;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ah.Testudin.Engine.State
{
    public class PausedApplicationState : ApplicationStateBase
    {
        #region Private Member Variables

        private ITestudinContentManager _contentManager;

        private IEventManager _eventManager;

        #endregion

        #region Constructors

        public PausedApplicationState()
            : base()
        {
            _contentManager = TestudinContentManagerSingleton.Instance;

            _eventManager = EventManagerSingleton.Instance;
        }

        #endregion

        #region IApplicationState

        public override void Load()
        {
            ICursor mouseCursor = new MouseCursor(
                20,
                20,
                _contentManager.Load<Texture2D>("Content/Sprites/default-cursor"));

            IGameView pausedMenuView = new HumanMenuView(
                new List<IScreenElement>()
                {
                    new ButtonScreenElement(
                        new Vector2(
                            300,
                            200),
                        200,
                        50,
                        _contentManager.Load<Texture2D>("Content/Sprites/ResumeButton"),
                        _contentManager.Load<Texture2D>("Content/Sprites/ResumeButtonHL"),
                        () => {
                            _eventManager.TriggerEvent(new GameResumedEvent());
                        })
                },
                mouseCursor);

            _gameViews.Add(pausedMenuView);
        }

        public override void Update(GameTime gameTime)
        {
            foreach (IGameView currentGameView in _gameViews)
            {
                currentGameView.Update(gameTime);
            }

            _eventManager.Update(gameTime);
        }

        public override void RenderDiagnostics(GameTime gameTime)
        {
            // Do nothing, yet
        }

        #endregion
    }
}
